//
//  CFMViewController.m
//  CFMProgressHUD
//
//  Created by Horcrux91 on 07/29/2019.
//  Copyright (c) 2019 Horcrux91. All rights reserved.
//

#import "CFMViewController.h"
#import <CFProgressHUDShowTool.h>
#import <UIImage+CFProgressHUD.h>

@interface CFMViewController ()

@end

@implementation CFMViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [CFProgressHUDShowTool showUserInteractiveIsSuccess:YES inView:self.view title:@"测试提示成功!"];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [CFProgressHUDShowTool showUserInteractiveIsSuccess:NO inView:self.view title:@"测试提示失败!"];
    });
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [CFProgressHUDShowTool showLoadDateIsSuccess:YES inView:self.view title:@"加载成功"];
    });
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [CFProgressHUDShowTool showLoadDateIsSuccess:NO inView:self.view title:@"加载失败"];
    });
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        CFProgressHUD *loadingHUD = [[CFProgressHUD alloc] init];
        loadingHUD.textLabel.text = @"努力加载中";

        CFProgressHUDImageIndicatorView *loadingIndicator = [[CFProgressHUDImageIndicatorView alloc] initWithAnimatedImages:[UIImage cf_hud_loadingImages]];
        loadingHUD.indicatorView = loadingIndicator;

        [loadingHUD showInView:self.view];

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [loadingHUD dismiss];
        });
    });
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end
